﻿using jbt.CodeCandy.AsTrEAM.Contracts;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Threading.Tasks;

namespace jbt.CodeCandy.AsTrEAM.Client
{
    /// <summary>
    /// Implements access to <see cref="IStreamManagerService"/>.
    /// </summary>
    public class StreamManagerServiceClient : ClientBase<IStreamManagerServiceClient>, IStreamManagerServiceClient
    {
        static StreamManagerServiceClient()
        {
            Factory = new StreamServiceClientFactory();
        }

        internal StreamManagerServiceClient(ServiceEndpoint endpoint)
            : base(endpoint)
        {
        }

        internal StreamManagerServiceClient(string endpointConfigurationName)
            : base(endpointConfigurationName)
        {
        }

        internal StreamManagerServiceClient(string endpointConfigurationName, string remoteAddress)
            : base(endpointConfigurationName, remoteAddress)
        {
        }

        /// <summary>
        /// Gets a factory what can create <see cref="IStreamManagerServiceClient"/> objects.
        /// </summary>
        public static StreamServiceClientFactory Factory
        {
            get;
            private set;
        }

        #region IStreamManagerServiceClient Members

        StreamData IStreamManagerServiceClient.Download(StreamDownloadRequest streamDownloadRequest)
        {
            return base.Channel.Download(streamDownloadRequest);
        }

        Task<StreamData> IStreamManagerServiceClient.DownloadAsync(StreamDownloadRequest streamDownloadRequest)
        {
            return base.Channel.DownloadAsync(streamDownloadRequest);
        }

        NewStreamResult IStreamManagerServiceClient.Upload(StreamData streamData)
        {
            return base.Channel.Upload(streamData);
        }

        Task<NewStreamResult> IStreamManagerServiceClient.UploadAsync(StreamData streamData)
        {
            return base.Channel.UploadAsync(streamData);
        }

        #endregion
    }
}